home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / Kamprath's CDEF Pack ƒ / Date & Time CDEF / Date & Time CDEF Description next >
Text File  |  1994-05-16  |  5KB  |  124 lines

  1. /***************************************************************************
  2.  
  3. Date & Time CDEF v1.1.1
  4. by Michael F. Kamprath
  5.  
  6. ©1993 by Michael F. Kamprath
  7.  
  8.  
  9. Requirments:
  10. ============
  11.  
  12. This CDEF can only be used with system 7.0 or later.  This is because
  13. this CDEF uses System 7's Color Icon family manager.
  14.  
  15. Description
  16. ===========
  17.  
  18. This CDEF will allow your program to use a point and click method for entering
  19. dates and/or times into your program.  (It will not, however, allow keyed 
  20. entering of dates.)  This CDEF uses the control record's hilite, value, and 
  21. refcon fields to manage what the current date value is, which part is hilited,
  22. and if the "up/down" button is active.   How the fields are used is as follows:
  23.  
  24.      (*theControl)->contrlHilite  = Control active (=0) or inactive (=255)
  25.                                     (also used to determine what part of the
  26.                                      up/down arrow is to be hilited during
  27.                                      tracking, but this is internal to the CDEF).
  28.      (*theControl)->contrlValue   = Determines which part of the date or time string
  29.                                      (depending on variation code) is to be hilited.
  30.                                      If it is nonzero, the the up/down arrow is
  31.                                      active and detects mouse clicks, otherwise
  32.                                      the up/down arrow is inactive (but drawn if
  33.                                      the hilite is not 255)
  34.      (*theControl)->contrlRfCon      = Contains a _pointer_ to the DateTimeRec to be
  35.                                      controled. 
  36.                                       
  37. This CDEF has two variations, one for time control (varCode=kTimeVariation), and 
  38. one for date control (varCode=kDateVariation).  Both variations use the current
  39. system setting for date and time display (except leading zeros are forced on all
  40. numeric fields).  
  41.  
  42. The basic scheme for using this CDEF is as follows:
  43.  
  44.   1.  #include "DateTimeCDEF.h" in your code.
  45.  
  46.   2. Initialize the control.  A typical initialization would be:
  47.   
  48.        hCtl = NewControl( theWindow, &ctrlRect, title, visible, 
  49.                         initialValue=0, min=0, max=128, 
  50.                         CDEF_ID*16 + varCode, refCon );
  51.   
  52.   It's rect should be about 175(long)x20(high) - fine
  53.   tune this value for your own application.  Also place the pointer to it's 
  54.   refcon field (either at initialization with NewControl() or ASAP with
  55.   GetNewControl() ).  If you want to control both the time and date to a single
  56.   DateTimeRec, put it's point in both the time and date variation controls.
  57.  
  58.   3. When a mouse down occurs within the control, track it as usual.  Then
  59.   if the returned part code is nonzero, do:
  60.   
  61.       If ( partcode != kArrowButtonUp) && ( partcode != kArrowButtonDown )
  62.           ==> Set the control value to the partcode returned.
  63.       Else
  64.           ==> If (control value != zero)
  65.                   ==> Increment or decrement the DateTimeRec according to
  66.                       the partCode returned.
  67.               Else
  68.                   ==> Impossible case.
  69.  
  70.   4. Upon activation or deactivation of the window (or even control), be
  71.   sure to set the -control hilite to either 0 or 255 (as per the situation
  72.   requires).
  73.   
  74.   5. When disposing the control, don't forget to dispoae the pointer to the 
  75.   DateTimeRec (that is, if you allocated a memory block for it rather than
  76.   using a stack variable).
  77.  
  78. If this confuses you, be sure to check out the code for the "CDEF Sampler"
  79. program included with this package.
  80.  
  81. NOTE: The icon id for the up/down arrow is hard coded into the CDEF at
  82. 15000.  You can change the icon supplied with this CDEF, but remember it
  83. should be a 16x16 icon family (ics#), and that the top half is considered
  84. the up button, and the bottom half is the down button.  Notice that 
  85. icon #15001 represents the "up button depressed" icon, and #15002 represents
  86. the "down button depressed" icon.  All of these (15000-15002) icons must
  87. be defined for the CDEF to work properly.
  88.  
  89. Shareware Info:
  90. ===============
  91.  
  92. If you use this CDEF for personal use, all I ask is that you send me a note
  93. and maybe a copy of the program you use it in.
  94.  
  95. If you use this CDEF for somethiong that you later charge money for (like
  96. your own shareware software or commercial software), the price for it's use
  97. is a one time payment of $5 and maybe a copy of your program.  If you don't 
  98. wish to give me a free copy of your program, I understand (after all, I'm 
  99. asking for money).  
  100.  
  101. If you wish for the source code to this CDEF, I will send it to you if you
  102. include a disk with your shareware payment ($5).  I will not send the source
  103. code out with out the shareware payment or the disk (though I will send it
  104. via e-mail if you send me the shareware payment before I lose my e-mail
  105. account).
  106.  
  107. Please make all payments in U.S. funds.
  108.  
  109. You may contact me by:
  110.  
  111.      e-mail:      kamprath@aol.com 
  112.  
  113.      postal mail: Michael F. Kamprath
  114.                   524 Avenue C
  115.                   Redondo Beach, CA  90277
  116.                                     
  117. Legal Stuff
  118. ===========
  119.  
  120. I provide no warranty, written or implied, nor do I accept any responsibility
  121. for damages inflicted, real or imagined, by the use of this CDEF.
  122.  
  123.  
  124. ***************************************************************************/